In this tutorial we will discuss performing co-registration of the multiple imaging modalities to the T1-weighted image.
2017-02-14
In this tutorial we will discuss performing co-registration of the multiple imaging modalities to the T1-weighted image.
library(ms.lesion) library(neurobase)
Loading required package: oro.nifti
oro.nifti 0.7.2
files = get_image_filenames_list_by_subject()$training01 t1_fname = files["MPRAGE"] t1 = readnii(t1_fname)
res = within_visit_registration(
fixed = files["MPRAGE"],
moving = files[c("T2", "FLAIR", "PD")],
typeofTransform = "Rigid",
interpolator = "Linear"
)
output_imgs = lapply(res, function(x) x$outfile)
names(output_imgs) = c("T2", "FLAIR", "PD")
out = c(MPRAGE = list(t1), output_imgs)
multi_overlay(out)
double_ortho(out$MPRAGE, out$T2 )
For a voxel \(v\), the rigid transformation can be written as:
\[T_{\rm rigid}(v) = Rv + t\] where \(R =\) \[\left[\begin{array}{ccc} \cos\beta\cos\gamma& \cos\alpha\sin\gamma + \sin\alpha\sin\beta\cos\gamma & \sin\alpha\sin\gamma - \cos\alpha\sin\beta\cos\gamma \\ -\cos\beta\sin\gamma & \cos\alpha\cos\gamma - \sin\alpha\sin\beta\sin\gamma & \sin\alpha\cos\gamma + \cos\alpha\sin\beta\sin\gamma \\ \sin\beta & -\sin\alpha\cos\beta & \cos\alpha\cos\beta \end{array}\right]\]
Image taken from http://cnl.web.arizona.edu/imageprops.htm
First, we will register scans within a visit to the T1 of that visit:
We will use the data from the Kirby21 dataset. Here we read in the T1 (denoted by MPRAGE) scan from visit 1:
From FSL: ``FLIRT (FMRIB's Linear Image Registration Tool) is a fully automated robust and accurate tool for linear (affine) intra- and inter-modal brain image registration''
Here we will register the scan with the skull on.
ANTsRThe extrantsr function preprocess_mri_within will do the following steps:
Now that the images are in the same space as the T1, if we skull-strip the T1 image, we can apply this mask to those images to extract brain tissues.
mask = readnii("../output/training01_01_mprage_mask.nii.gz")
sub_mask = applyEmptyImageDimensions(mask, inds = dd$inds)
masked_imgs = lapply(xout, mask_img, sub_mask)
orthographic(masked_imgs[[2]])
ants_regwrite wraps around the reading/writing of images and applying transformationsdouble_ortho and ortho2 can provide some basic visual checks to assess registration qualitypreprocess_mri_within and preprocess_mri_across are general wrapper functions to process MRI data